<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>文档</title>
  <link href="../css/semantic/semantic.min.css" rel="stylesheet">
  <link href="../css/markdown.css" rel="stylesheet">
  <link href="../css/wtxynavigation.css" rel="stylesheet">
  <script src="../js/jquery.min.js"></script>
  <script type="text/javascript" src="../js/include.js"></script>
  <style>
    body{padding-top:0;background:#f7f7f7}
    body>.ui.container{width:100%;padding:0}
    #project-title{background:#6e6e6e;width:100%;line-height:3.572rem;color:#fff;font-size:1.2rem}
    #project-title .title-wrap{font-weight:700;padding:0 12px;width:100%;max-width:1366px!important;min-width:900px;margin:0 auto}
    #project-title .left,#project-title right{display:inline-block}
    #project-title .right{float:right}
    #project-title .right .wiki-actions .menu{left:auto;right:0;margin-top:.4em!important}
    #wiki-preview-container{width:100%;max-width:1366px!important;min-width:900px;padding:0;border:1px solid #e3e9ed;border-top:0}
    #wiki-preview>.ui.segment{margin-top:0;padding:1rem;padding-left:0;border:0}
    .hover-places{display:inline-block}
    #page-detail{width:60%;margin:0 auto}
    #page-detail .title{font-weight:700;font-size:24px;padding:12px 0;border-bottom:1px solid #ccc}
    #page-detail .content{margin-top:15px}
    .content p{word-wrap:break-word}
    #wiki-parent,#wiki-title,#wikis{display:none}
    .ui.grid{padding:0!important}
    #ex-all{cursor:pointer;color:#537c8d}
  </style>
</head>
<body>
  <div class="ui container">
    <div id="project-title">
      <div class="title-wrap">
        <div class="left">
          <i class="icon eye"></i>
          文档预览:
          mianmSDK
        </div>
        <div class="right">
          Export by Gitee
        </div>
      </div>
    </div>

    <div class="ui container" id="wiki-preview-container">
      <div id="wiki-preview">
        <div class="ui segment">
          <div id="page-detail" class="markdown-body">
            <div class='title'>30.runtime动态方法解析</div><div class='content'><h1>
<a id="runtime动态方法解析" class="anchor" href="#runtime%E5%8A%A8%E6%80%81%E6%96%B9%E6%B3%95%E8%A7%A3%E6%9E%90"></a>runtime动态方法解析</h1>
<p><strong>关键词</strong>: <code>runtime</code>,<code>@dynamic</code>,<code>dynamic</code></p>
<h1>
<a id="1-dynamic" class="anchor" href="#1-dynamic"></a>1. @dynamic</h1>
<ul>
<li>
<ol>
<li>
<strong>@dynamic</strong>: 修饰属性的</li>
</ol>
</li>
<li>
<ol start="2">
<li>
<strong>@dynamic</strong>: 在实现里面(<code>@implementation</code>)使用</li>
</ol>
</li>
<li>
<ol start="3">
<li>使用了**@dynamic**,我们的<code>getter</code>和<code>setter</code>方法就是运行时添加,而不是编译时添加</li>
</ol>
</li>
</ul>
<p><strong>当我们把一个属性标识为@dynamic的时候, 代表着不需要编译器在编译时为我们的属性,生成</strong></p>
<p><img src="images/runtimeDynamic01.png" alt="runtimeDynamic01"></p>
<p><img src="images/runtimeDynamic02.png" alt="runtimeDynamic02">
<img src="images/runtimeDynamic03.png" alt="runtimeDynamic03"></p>
<h1>
<a id="2-动态运行时语言" class="anchor" href="#2-%E5%8A%A8%E6%80%81%E8%BF%90%E8%A1%8C%E6%97%B6%E8%AF%AD%E8%A8%80"></a>2. 动态运行时语言</h1>
<ul>
<li>
<p><strong>动态运行时语言</strong>将<strong>函数决议</strong>推迟到运行时</p>
<ul>
<li>当我们把一个属性标识为**@dynamic<strong>的时候,代表着不需要编译器在编译时为我们生成<code>getter</code>和<code>setter</code>方法的具体实现, 而是在运行时我们调用了<code>getter</code>和<code>setter</code>方法的时候再去为它添加具体的实现.这种特性只有</strong>动态运行时语言**支持这种功能.</li>
<li>就是在运行时为这个方法添加,具体的执行函数</li>
</ul>
</li>
<li>
<p>编译时语言在编译期进行<strong>函数决议</strong></p>
<ul>
<li>就是在编译期间就已经确定了,方法名称所对应的函数执行体, 在运行的过程中是没法修改的</li>
</ul>
</li>
</ul>
<h1>
<a id="答" class="anchor" href="#%E7%AD%94"></a>答:</h1></div>
          </div>
        </div>
      </div>
      </div>
  </div>
</body>
</html>